#根目录下执行：docker build -t test1  -f Dockerfile .
FROM golang:1.17 AS builder

WORKDIR /build
ENV GOPROXY https://goproxy.cn
COPY go.mod .
COPY go.sum .
RUN go mod download

COPY . .
RUN CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o test1 ./cmd


FROM ubuntu
ENV TZ Asia/Shanghai

WORKDIR /app
COPY --from=builder /build/test1 /app/
COPY --from=builder /build/configs /app/configs

CMD ["/app/test1","-log.dir","/data/logs/test1","-conf","/app/configs","-deploy.env","pre","-log.agent","unixgram:///var/agent/sock_1122?timeout=100ms&chan=1024"]

#docker run -v /tmp/agent/:/var/agent -d test1:latest


###################################################
#根目录下执行：docker build -t test1  -f Dockerfile .
#FROM golang:1.17-alpine AS builder

#WORKDIR /build
#RUN adduser -u 10001 -D app-runner

#ENV GOPROXY https://goproxy.cn
#COPY go.mod .
#COPY go.sum .
#RUN go mod download

#COPY . .
#RUN CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o test1 ./cmd

#FROM alpine AS final
#WORKDIR /app
#COPY --from=builder /build/test1 /app/
#COPY --from=builder /build/configs /app/configs
#COPY --from=builder /etc/passwd /etc/passwd
#COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

#USER app-runner

#CMD ["/app/test1","-log.dir","/data/logs/test1","-conf","/app/configs"]